package priv.stones.jdbc;

import com.mysql.cj.api.mysqla.result.Resultset;

import java.lang.management.ManagementFactory;
import java.sql.*;

/**
 * @Author: Stones
 * @Description:
 * @Date: 2017/9/27 11:13
 */
public class Jdbc2 {

    public static void main(String[] args) throws SQLException {

        Connection cn = DriverManager.getConnection("jdbc:mysql://localhost:3306/spider1?serverTimezone=UTC&characterEncoding=utf8&useSSL=true&useUnicode=true",
                "root", "Hujinyang1");

        PreparedStatement preparedStatement=cn.prepareStatement("SELECT * FROM spider1.test");

        ResultSet rs = preparedStatement.executeQuery();

        while (rs.next()) {

            int id = rs.getInt("id");
            String name = rs.getString("name");
            int age = rs.getInt("age");
            System.out.println("id=" + id + "   name=" + name + "   age=" + age);

        }


        cn.close();


    }

}
